package com.zxp.security.jwt;

import com.google.common.collect.Maps;
import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
import org.springframework.security.oauth2.provider.token.TokenEnhancer;

import java.util.HashMap;

/**
 * oauth里面加上自定的数据
 * @author shollin
 * @desc
 * @date 2021/7/11/011 23:24
 */
public class MyJwtTokenEnhancer implements TokenEnhancer {

    @Override
    public OAuth2AccessToken enhance(OAuth2AccessToken accessToken, OAuth2Authentication authentication) {
        HashMap<String, Object> params = Maps.newHashMap();
        params.put("author","zxp");
        ((DefaultOAuth2AccessToken) accessToken).setAdditionalInformation(params);
        return accessToken;
    }
}
